<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text" placeholder="姓名" id="name_input">
<input type="text" placeholder="工资" id="salary_input">
<input type="text" placeholder="工作" id="job_input">
<input type="button" value="添加" onclick="add()">
<table border="1">
  <caption>员工列表</caption>
  <tr>
    <th>姓名</th><th>工资</th><th>工作</th>
  </tr>
</table>
<script>
    let nameInput = document.querySelector("#name_input");
    let salaryInput = document.querySelector("#salary_input");
    let jobInput = document.querySelector("#job_input");
  function add() {
    //创建tr和3个td
    let tr = document.createElement("tr");
    let nameTd = document.createElement("td");
    let salaryTd = document.createElement("td");
    let jobTd = document.createElement("td");
    //设置显示的内容
    nameTd.innerText = nameInput.value;
    salaryTd.innerText = salaryInput.value;
    jobTd.innerText = jobInput.value;
    //把td装进tr
    tr.append(nameTd,salaryTd,jobTd);
    //得到table 把tr装进table
    let table = document.querySelector("table");
    table.append(tr);
  }
</script>
</body>
</html>